home *** CD-ROM | disk | FTP | other *** search
/ Shareware Overload Trio 2 / Shareware Overload Trio Volume 2 (Chestnut CD-ROM).ISO / dir30 / eerems11.zip / EEREM.DOC < prev    next >
Text File  |  1994-08-09  |  16KB  |  416 lines

  1. Documentation for Extra Entity REMoval version 1.0         August 7, 1994
  2.  
  3. Jon Fleming CIS 70334,2443
  4.  
  5. WHAT IS EEREM?
  6.  
  7.        EEREM is a package written in C for the AutoCAD ADS environment.
  8.    It removes a large set of possible "extra entities" from an AutoCAD
  9.    drawing.  An "extra entity" is one which adds no information to the
  10.    drawing, such as duplicate lines.  Extra entities can arise from many
  11.    situations.  One situation that can give rise to MANY extra entities
  12.    is projecting a 3D wireframe model into 2D with PROJECT.LSP (included
  13.    with AutoCAD) or the equivalent.
  14.        Extra entities are inconvenient because they increase drawing file
  15.    size, lead to unexpected OSNAP results, and cause clogging of pens in
  16.    pen plotters forced to trace the same path several times.
  17.  
  18. BOILERPLATE
  19.  
  20.        EEREM is public domain.  You may do what you want with it; please
  21.    credit me if you use the code or any significant portion of it in
  22.    your programs.
  23.        I expect EEREM to do what it is described as doing.  However,
  24.    EEREM is supplied "as-is" with no warranty of mercantability or
  25.    fitness for a particular purpose.  I accept no responsibility for its
  26.    operation or damages of any kind.
  27.        If you bring problems to my attention, I will do what I can to
  28.    resolve them.
  29.  
  30. WHAT DO I NEED TO USE EEREM?
  31.  
  32.        This incarnation of EEREM has been tested under AutoCAD Release
  33.    12 c3 DOS and AutoCAD Release 12 c4 Windows. It may run under higher
  34.    release numbers, I cannot determine that at this time.  If
  35.    appropriately compiled, it _should_ run on other platforms.
  36.  
  37.        For some reason I don't understand, EEREM does not work as well
  38.    on polylines under Windows as it does under DOS.
  39.  
  40.        EEREM will NOT work under AutoCAD Release 11 or previous.
  41.  
  42.        WARNING:  Although I cannot prove it, I think that earlier
  43.    releases of AutoCAD 12 had bugs in the ads_ssget() "X" interface which
  44.    led to EEREM missing many entities it should delete.  If EEREM does
  45.    not do the job for you, and you are running an older release of R12,
  46.    upgrade to the current release.
  47.  
  48. HOW DO I USE EEREM?
  49.  
  50.        First, copy EEREM.EXP and EEREM.DCL into a directory (or
  51.    directories) that is (are) listed in the AutoCAD "ACAD" environment
  52.    variable.
  53.  
  54.        EEREM must be loaded into memory.  At the AutoCAD "Command:"
  55.    prompt, you may type:
  56.  
  57.    (xload "eerem")
  58.  
  59.    (note:  once you have loaded EEREM, you need not do it again until you
  60.    have exited and re-entered AutoCAD.  This is different from LISP
  61.    programs which you must load every time you move from one drawing to
  62.    another without exiting AutoCAD).
  63.  
  64.        Once EEREM is loaded, at the AutoCAD "Command:" prompt, type:
  65.  
  66.    ddeerem
  67.  
  68.    Then click on the "Select Entities for Checking" button, select a set
  69.    of entities to check, and click on the OK button.
  70.  
  71.        See "ADVANCED EEREM USAGE", below, for hints and suggestions on
  72.    how to use EEREM efficiently; explanations of the other items in the
  73.    dialog box; and using EEREM from your own AutoLISP or C program.
  74.  
  75. WHAT ENTITIES DOES EEREM REMOVE?
  76.  
  77.        First, a pair of definitions:
  78.  
  79.    duplicate entity = an entity that covers EXACTLY the same extents as
  80.                       another entity.
  81.  
  82.    underlying entity = an entity that DOES NOT cover exactly the same
  83.                        extents as another entity but is completely
  84.                        covered by that other entity.
  85.  
  86.    For example, if there's a line from (0,0,0) to (1,0,0), then another
  87.    line from (0,0,0) to (1,0,0) is a DUPLICATE entity.  Lines from (for
  88.    example) (0,0,0) to (0,0,0) or from (0.25,0,0) to (0.75,0,0) are
  89.    UNDERLYING entities.
  90.  
  91.        Briefly (see "DETAILED ENTITY REMOVAL SPECIFICATIONS", below, for
  92.    more detail), EEREM removes:
  93.  
  94.    All line duplicates and lines that underlie other lines (including
  95.        "zero-length" lines if they underlie a non-zero-length line).
  96.  
  97.    All circle duplicates and arcs that underlie circles (circles
  98.        underlying circles are duplicate circles!).
  99.  
  100.    All arc duplicates and arcs that underlie arcs.
  101.  
  102.    All duplicate points (points underlying points are the same as
  103.        duplicate points!)
  104.  
  105.    Most 2D and 3D (but not mesh) polyline duplicates and most 2D and 3D
  106.        (but not mesh) polylines that underlie other 2D and 3D (but not
  107.        mesh) polylines
  108.  
  109. WHAT COMMON EXTRA ENTITIES ARE _NOT_ REMOVED?
  110.  
  111.        Different-type entities, such as polylines underlying lines.
  112.    (such entities are often created by PROJECT.LSP; all versions that
  113.    I've examined project all circles and arcs as polylines even when a
  114.    line or arc or circle would be more appropriate.  I haven't examined
  115.    the Release 12 PROJECT.LSP).
  116.  
  117.        Entities that appear to overlay each other on the screen but are
  118.    actually far enough apart for EEREM to consider them different.
  119.  
  120.        Entities that overlap, but neither entity completely covers the
  121.    other.
  122.  
  123. HINTS
  124.  
  125.         EEREM will run _much_ more slowly if there are a lot of entities
  126.    in the drawing that are not involved in EEREM's operation.  This is
  127.    because EEREM asks AutoCAD to search the entire drawing database for
  128.    entities that may be deleted, and does so many times.  (Other
  129.    algorithms that I thought of proved to be much slower in 99% of the
  130.    cases).
  131.         Always run EEREM in a drawing that contains as few entities as
  132.    possible.  The AutoCAD WBLOCK command is often useful for creating
  133.    temporary drawings on which to run EEREM.
  134.  
  135. ADVANCED EEREM USAGE:  EASY LOADING
  136.  
  137.        AutoCAD Release 12 includes a sophisticated automatic loading
  138.    facility for command-line-callable functions.  To activate this, if
  139.    you DO NOT have an S::STARTUP function in ACAD.LSP, add the following
  140.    to ACAD.LSP:
  141.  
  142.    (defun S::STARTUP ()
  143.      (autoxload "EEREM" '("DDEEREM"))
  144.    )
  145.  
  146.    If you already have a S::STARTUP function in ACAD.LSP, add the
  147.    following to it:
  148.  
  149.      (autoxload "EEREM" '("DDEEREM"))
  150.  
  151.        For usage from AutoLISP, the following works:
  152.  
  153.      (if eerem
  154.        (eerem sel_set)
  155.        (if (xload "EEREM")
  156.          (eerem sel_set)
  157.          (prompt "\nCan't locate EEREM.EXP!")
  158.        )
  159.      )
  160.  
  161. ADVANCED EEREM USAGE:  FROM THE "COMMAND:" PROMPT
  162.  
  163.        I hope the three check boxes at the top of the dialog box are
  164.    self-explanatory.  For example, say there's a line from (0,0,0) to
  165.    (1,0,0) on layer "0", and another line from (0,0,0) to (1,0,0) on
  166.    layer "DUMMY".  If the "Entities on different layers are different"
  167.    check box IS NOT checked, EEREM will remove one of these entites
  168.    (which one depends on their order in the set of entities selected for
  169.    checking).  If the "Entities on different layers are different" check
  170.    box IS checked, EEREM will not remove either entity.  The other two
  171.    check boxes behave in an analogous fashion.
  172.  
  173.        There is one aspect that may be counterintuitive.  The colors or
  174.    linetypes BYLAYER or BYBLOCK are always considered different from an
  175.    explicit color or linetype.  For example, say there are two lines that
  176.    are identical in every respect, including what layer they are on,
  177.    except one has color BYLAYER and one has color YELLOW.  Say also that
  178.    the default color of the layer is YELLOW.  The two lines appear
  179.    identical on screen, but if the "Entities with different colors are
  180.    different" checkbox is checked EEREM will _not_ remove either line.
  181.  
  182.        You probably don't want to change the "Tolerance" value, but you
  183.    can try it if you want.  Briefly, the tolerance is a measure of how
  184.    far apart points must be before EEREM considers them unequal (see
  185.    "DETAILED ENTITY REMOVAL SPECIFICATIONS", below, for more
  186.    explanation).  The tolerance is in drawing units.
  187.  
  188. ADVANCED EEREM USAGE:  FROM AUTOLISP
  189.  
  190.        The dialog box version of EEREM may be called from AutoLISP by:
  191.  
  192.    (ddeerem)
  193.  
  194.    There is no return value.
  195.  
  196.        To call the EEREM core engine without putting up a dialog box,
  197.    use:
  198.  
  199.    (eerem sel_set checklayer checkltype checkcolor tolerance)
  200.  
  201.    where:
  202.  
  203.        sel_set is a selection set of entities to check, and is required.
  204.  
  205.        checklayer is NIL to count entities on different layers as the same,
  206.        non-NIL to count entities on different layers as different.  checklayer
  207.        is optional (default NIL) unless one or more of the following arguments
  208.        are supplied.
  209.  
  210.        checkltype is NIL to count entities with different linetypes as the
  211.        same, non-NIL to count entities with different linetypes as different.
  212.        checkltype is optional (default NIL) unless one or more of the
  213.        following arguments are supplied.
  214.  
  215.        checkcolor is NIL to count entities with different colors as the same,
  216.        non-NIL to count entities with different colors as different.
  217.        checkcolor is optional (default NIL) unless one or more of the
  218.        following arguments are supplied.
  219.  
  220.        tolerance is a real number that measures how close points must be to
  221.        be considered the same (well, approximately; see "DETAILED ENTITY
  222.        REMOVAL SPECIFICATIONS", below, for more detail).  tolerance is
  223.        optional.  The default is 0.00001.
  224.  
  225.    (eerem ...) returns NIL if an error was detected or T otherwise.
  226.  
  227. ADVANCED EEREM USAGE:  FROM ADS
  228.  
  229.        Call ddeerem through ads_invoke().  The return values are RSRSLT
  230.    (no error detected) or RSERR (can't find DCL file).
  231.  
  232.        Call eerem through ads_invoke() with a list corresponding to the
  233.    AutoLISP parameters.  The return values are RSRSLT (corresponding to
  234.    the AutOLISP "T" return values, above) or RSERR (corresponding to the
  235.    AutoLISP "NIL" return values, above).
  236.  
  237.        I haven't tested this.
  238.  
  239. DETAILED ENTITY REMOVAL SPECIFICATIONS:  GENERAL
  240.  
  241.        All entity removal is based on a "current" entity and a
  242.    "candidate" entity.  The current entity is one of the set of entities
  243.    that was selected for extra entity removal, and must be a LINE,
  244.    non-mesh POLYLINE, CIRCLE, ARC, or POINT.  Other entity types, in the
  245.    set of entities selected for extra entity removal, are skipped.  The
  246.    candidate is the same type of entity as the current entity but MAY OR
  247.    MAY NOT be in the set of entities selected for extra entity removal;
  248.    all possible candidates in the drawing are checked.  The candidate is
  249.    the entity which will be deleted if it meets the criteria listed in
  250.    the following sections.
  251.  
  252.        All combinations of current and candidate entities are checked.
  253.    Most of the filtering of candidate entities is done through the
  254.    ads_ssget() "X" mechanism, yielding a (usually) small set of
  255.    candidate entities that require further checking.  I think it is a
  256.    failure of the ads_ssget "X" mechanism to return the proper set of
  257.    entities that makes EEREM work improperly in early versions of R12
  258.    when the viewpoint is not "plan UCS".
  259.  
  260.        Note that entity thickness IS NEVER CHECKED; if two entities are
  261.    the same except for thickness, one of them will be removed!
  262.  
  263.        The following sections do not discuss whether or not the current
  264.    and candidate entity's layer, color, or linetype matter.  If the
  265.    appropriate flag(s) is(are) set, through the dialog box or through a
  266.    parameter to the function, unsuitable candidates are filtered out by
  267.    ads_ssget() "X".
  268.  
  269. DETAILED ENTITY REMOVAL SPECIFICATIONS:  LINES
  270.  
  271.        The candidate line is deleted if both its endpoints lie within a
  272.    cylinder of radius "tolerance", centered on the current line and the
  273.    same length as the current line.
  274.  
  275.        Lines shorter than 0.0001 times "tolerance" are not considered as
  276.    "current" entities, because the algorithm blows up for coincident
  277.    current line endpoints.  The presumption is that such short (or even
  278.    zero-length) lines are extremely likely to be underlying some other
  279.    line.
  280.  
  281. DETAILED ENTITY REMOVAL SPECIFICATIONS: CIRCLES & UNDERLYING ARCS
  282.  
  283.        When the current entity is a circle, a candidate circle or arc is
  284.    deleted if:
  285.  
  286.    its center lies within a cube of side two times "tolerance", centered
  287.    on the center of the current circle
  288.  
  289.        AND
  290.  
  291.    the candidate's radius is within plus or minus "tolerance" of the
  292.    current circle's radius
  293.  
  294.        AND
  295.  
  296.    the distance from the tip of the candidate's extrusion vector to
  297.    EITHER the tip of the current circle's extrusion vector OR the tip of
  298.    a unit vector directly opposite the current circle's extrusion vector
  299.    is less than "tolerance".
  300.  
  301. DETAILED ENTITY REMOVAL SPECIFICATIONS:  POINTS
  302.  
  303.        A candidate point is deleted if it lies within a cube of side two
  304.    times "tolerance", centered on the current point entity.
  305.  
  306. DETAILED ENTITY REMOVAL SPECIFICATIONS:  ARCS
  307.  
  308.        When the current entity is an arc, a candidate arc is deleted if:
  309.  
  310.    its center lies within a cube of side two times "tolerance", centered
  311.    on the center of the current arc
  312.  
  313.        AND
  314.  
  315.    the candidate's radius is within plus or minus "tolerance" of the
  316.    current arc's radius
  317.  
  318.        AND
  319.  
  320.    the start and end points of the candidate arc are on or between the
  321.    start and end points of the current arc
  322.  
  323.        AND
  324.  
  325.    the distance from the tip of the candidate's extrusion vector to
  326.    EITHER the tip of the current arc's extrusion vector OR the tip of
  327.    a unit vector directly opposite the current arc's extrusion vector
  328.    is less than "tolerance".
  329.  
  330. DETAILED ENTITY REMOVAL SPECIFICATIONS:  POLYLINES
  331.  
  332.        Both the current and candidate polylines may not be 3D polygon
  333.    meshes; such entities are skipped if they occur in the set of
  334.    entities to check.
  335.  
  336.        Ready?  This is the BIG ONE!  Onward ...
  337.  
  338.        A candidate polyline is deleted if:
  339.  
  340.    its elevation is within plus or minus "tolerance" of the elevation of
  341.    the current polyline
  342.  
  343.        AND
  344.  
  345.    the candidate's start and end widths are within plus or minus
  346.    "tolerance" of the current polyline's start and end widths,
  347.    respectively
  348.  
  349.        AND
  350.  
  351.    the candidate's polyline type and curve fit type are the same as the
  352.    current polyline
  353.  
  354.        AND
  355.  
  356.    the distance from the tip of the candidate's extrusion vector to the
  357.    tip of the current polyline's extrusion vector is less than
  358.    "tolerance" (note that, unlike circles and arcs, polylines with
  359.    extrusion vectors exactly opposite to that of the current polyline
  360.    are not checked for deletion)
  361.  
  362.        AND
  363.  
  364.    for each successive vertex of the candidate, there is a vertex of the
  365.    current polyline that:
  366.  
  367.        immediately follows the last current polyline vertex that matched
  368.        the previous candidate polyline vertex
  369.  
  370.             AND
  371.  
  372.        matches the current candidate polyline vertex.
  373.  
  374.  
  375.        In the above, "matches" means that:
  376.  
  377.    the distance from the candidate vertex to the current polyline vertex
  378.    is less than "tolerance"
  379.  
  380.        AND
  381.  
  382.    the candidate vertex's start and end widths are within plus or minus
  383.    "tolerance" of the current polyline vertex's start and end widths,
  384.    respectively
  385.  
  386.        AND
  387.  
  388.    the candidate vertex's bulge factor is within plus or minus
  389.    "tolerance" of the current polyline vertex's bulge factor
  390.  
  391.        AND
  392.  
  393.    the distance from the tip of the candidate vertex's tangent vector to
  394.    the tip of the current polyline vertex's tangent vector is less than
  395.    "tolerance"
  396.  
  397.        AND
  398.  
  399.    the current vertex's flag bits (group 70) are the same as the flag
  400.    bits of the current polyline vertex.
  401.  
  402.  
  403.    (Whoof!  That was almost as hard to write down precisely as it was to
  404.    figure out!)
  405.  
  406. COMPILING EEREM:
  407.  
  408.        EEREM was compiled for DOS or Windows using Watcom C/C++-32 9.5.
  409.    A .MAK file is included (in the source code package) for Watcom WMAKE.
  410.  
  411.        Hints:  be careful when asking the compiler to do agressive
  412.    optimization; when I used "opmaxet" EEREM appeared to work but never
  413.    removed any polylines.  Be sure to delete *>OBJ or TOUCH *.C when
  414.    changing from compiling for Windows to compiling for DOS or vice
  415.    versa.
  416.